Cleaning up
[andmenj-acm.git] / 11505 - Logo / 11505.cc
blob82a88cb275e7fd08391f5efc2ab2e10535328f73
1 #include <iostream>
2 #include<math.h>
3 #include<stdio.h>
4 #include<assert.h>
5 #include<string>
6 using namespace std;
7 const double pi=acos(-1);
8 inline double toRad(const double anl){
9 return anl*pi/180.0;
11 int main(){
12 int cases;
13 cin>>cases;
14 for(int n;cases-- &&cin>>n;){
15 double t,x=0,y=0,teta=0;
16 for(string ins;n-- && cin>>ins>>t;){
17 if(ins=="fd"){
18 x+=t*cos(teta);
19 y+=t*sin(teta);
20 }else if(ins=="bk"){
21 x-=t*cos(teta);
22 y-=t*sin(teta);
23 }else if(ins=="lt"){
24 teta+=toRad(t);
25 }else if(ins=="rt"){
26 teta-=toRad(t);
27 }else{
28 assert(false);
31 printf("%.0lf\n",sqrt(x*x+y*y));
33 return 0;